class Storage {
  private constructor() {}

  /**
   * @param key constant 定义的常量 KEY
   * @param defaultReturn 默认返回值，如果localStorage查不到数据，可以指定默认返回值
   */
  static getStorage(key: string, defaultReturn: any = '') {
    const res = localStorage.getItem(key)
    if (res == null) {
      return defaultReturn
    }
    return res
  }

  static setStorage(key: string, val: any) {
    localStorage.setItem(key, val)
  }

  static remove(key: string) {
    localStorage.removeItem(key)
  }

  static removeAll() {
    localStorage.clear()
  }
}

export default Storage
